1 '                      NORMAL DISTRIBUTION
2 '               Written by Tracy L. Gustafson, M.D.
3 '              Round Rock, Texas. Version 3.0, 1984
4 ON ERROR GOTO 5000:CHAIN MERGE "EPIMRG",5
15 DIM D(1,1),CS(1,1),T(1),N$(1),X(1),X2(1),MD(1),SD(1)
22 DATA "NORMAL DISTRIBUTION",28,21
30 DQ="Do you want to evaluate another ":PRINT:PRINT LEFT$(DQ,14);":":PRINT
35 PRINT TAB(10);"1.)  Determine if the mean of your sample is significantly":PRINT TAB(16);"different from the population mean.":PRINT
40 PRINT TAB(10);"2.)  Determine what percent of test values lie within":PRINT TAB(16);"a given range.":PRINT
45 PRINT TAB(10);"3.)  Evaluate a known Z value."
50 LOCATE 16,18:INPUT "Enter choice:   ",ASUB:IF ABS(ASUB-2)>1 THEN BEEP:GOTO 50
55 ON ASUB GOTO 60,130,195
60 CLS:PRINT TAB(8);"COMPARING SAMPLE MEAN TO POPULATION MEAN (two-tailed Z test)":PRINT TAB(8);STRING$(60,205)
65 LOCATE 5,8:PRINT "(Enter RETURN if you want to enter known MEAN and STD. DEV.)"
70 LOCATE 4,1:GOSUB 4000
75 PRINT:PRINT:AR=CSRLIN:PRINT TAB(10);"What is the SAMPLE NUMBER you wish to analyze?";:AC=58:GOSUB 4200
80 PRINT:PRINT TAB(25);"This sample has a MEAN of";X(NS)/T(NS):PRINT
85 PRINT TAB(10);:INPUT "What is the POPULATION MEAN for this variable?   ",M
90 XZ=(X(NS)/T(NS)-M)/SD(NS):GOSUB 220
95 LOCATE 25,8:PRINT DQ;"MEAN using this DATAFILE?  ";:INPUT;"",A$:IF A$="y" OR A$="Y" THEN CLS:GOTO 75 ELSE 210
100 PRINT:PRINT:PRINT TAB(25);
105 INPUT "What is the SAMPLE MEAN?   ",SM:PRINT:PRINT TAB(21);
110 INPUT "What is the POPULATION MEAN?   ",M:PRINT:PRINT TAB(11);
115 INPUT "What is the SAMPLE STANDARD DEVIATION?   ",SV
120 XZ=(SM-M)/SV:GOSUB 220
125 LOCATE 25,12:PRINT DQ;:INPUT;"known SAMPLE MEAN?  ",A$:IF A$="y" OR A$="Y" THEN CLS:GOTO 100 ELSE 210
130 CLS:PRINT TAB(17);"PERCENT OF TEST VALUES IN A GIVEN RANGE":PRINT TAB(17);STRING$(39,205)
135 LOCATE 5,20:INPUT "What is the MEAN of this test?   ",SM
140 LOCATE 7,15:INPUT "What is the STANDARD DEVIATION of this test?   ",SV
145 LOCATE 9,20:PRINT "Enter limits of RANGE in question:":PRINT TAB(21);"LOWER LIMIT";TAB(41);"UPPER LIMIT"
150 PRINT TAB(25);:INPUT;"",LL:PRINT TAB(45);:INPUT "",UL
155 XZ=(LL-SM)/SV:GOSUB 180:PC=P
160 XZ=(UL-SM)/SV:GOSUB 180:PC=(PC-P)*100
165 COLOR CLR2,CLR1:GOSUB 250
170 PRINT TAB(12);"The PERCENT of test values in this range = ";:IF PC<100 THEN PRINT PC; ELSE PRINT "> 99.99999";
175 PRINT TAB(79):COLOR CLR1,CLR2:LOCATE 25,15:PRINT DQ;:INPUT;"TEST RANGE?  ",A$:IF A$="y" OR A$="Y" THEN 130 ELSE 210
180 IF ABS(XZ)>6 THEN P=0 ELSE GOSUB 240:P=PT*R
185 IF XZ<0 THEN P=1-P
190 RETURN
195 CLS:PRINT TAB(12);"EVALUATING Z VALUE - NORMAL DISTRIBUTION (two-tailed)":PRINT TAB(12);STRING$(53,205)
200 LOCATE 5,25:INPUT "Enter Z value:   ",XZ:GOSUB 220
205 LOCATE 25,20:PRINT DQ;:INPUT;"Z value?  ",A$:IF A$="y" OR A$="Y" THEN 195
210 LOCATE 25,3:INPUT;"Do you want to perform another analysis using the NORMAL DISTRIBUTION?  ",A$:IF A$="y" OR A$="Y" THEN 20
215 LOCATE 23,1:END
220 IF ABS(XZ)>6 THEN P=0:GOTO 225 ELSE GOSUB 240:P=2*PT*R
225 GOSUB 250:COLOR CLR2,CLR1:PRINT TAB(28);"P = ";
230 IF P<.000001# THEN PRINT "< 10 (-6)";TAB(65) ELSE PRINT P;TAB(65)
235 COLOR CLR1,CLR2:RETURN
240 R=1/SQR(EXP(XZ*XZ)*6.283185307#):W=1/((ABS(XZ)*.2316419)+1)
245 W2=W*W:PT=(W*.31938153#)-(W2*.356563782#)+(W*W2*1.781477937#)-(W2*W2*1.821255978#)+(W2*W2*W*1.330274429#):RETURN
250 PLAY "MB ML T180 L8 O1 E- L16 O4 E-GB- O5 E- O4 B-GE- O1 L3 E-"
255 PRINT:PRINT:PRINT TAB(10);:RETURN
4010 IF FILE$="" THEN 100
4025 ERASE D,CS,T,N$,X,X2,MD,SD
4030 DIM D(A,C),CS(A,C),T(A),N$(A),X(A),X2(A),MD(A),SD(A)
5000 BEEP:IF ERR<>53 AND ERR<>71 THEN 5010 ELSE LOCATE 10,10:PRINT "Please place EPISTAT in drive A: (or other default).":PRINT TAB(25);"Press any key to continue:"
5005 A$=INKEY$:IF A$="" THEN 5005 ELSE RESUME
5010 ON ERROR GOTO 0:END
